import 'package:flutter/material.dart';
import '../More/More.dart';
import '../Splash.dart';
import '../DouBao/DouBao.dart';
import '../Setting/Setting.dart';

class MyHomePage extends StatefulWidget {
  const MyHomePage({Key? key}) : super(key: key);

  @override
  State<MyHomePage> createState() => _MyHomePageState();
}

class _MyHomePageState extends State<MyHomePage> {
  int  _currentIndex = 0;

  final List<Widget> _page=[
    // 豆包
    const DouBao(),
    // 智能体
    const More(),
    // 我的页面
    const MinePage(),
  ];

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      body: _page[_currentIndex],
      floatingActionButton: _currentIndex != 1 ? Container() :
      FloatingActionButton(
        heroTag: 'HeroTag',
        child: Icon(Icons.flutter_dash),
        onPressed: () {
          Navigator.push(
            context,
            MaterialPageRoute(builder: (context) => const SplashScreen()),
          );
        },
      ),
      bottomNavigationBar: BottomNavigationBar(
        currentIndex: _currentIndex,
        //BottomNavigationBar 的点击事件
        onTap: (flag) {
          setState(() {
            _currentIndex = flag;
          });
        },
        fixedColor: Colors.black,
        type: BottomNavigationBarType.fixed,
        items: [
          BottomNavigationBarItem(
            icon: Image.asset(
              'assets/images/message_unselect.webp',
              height: 20,
              width: 20,
            ),
            activeIcon: Image.asset(
              'assets/images/message_select.webp',
              height: 25,
              width: 25,
            ),
            label: ('对话'),
          ),
          BottomNavigationBarItem(
            icon: Image.asset(
              'assets/images/search_unselect.webp',
              height: 20,
              width: 20,
            ),
            activeIcon: Image.asset(
              'assets/images/search_select.webp',
              height: 25,
              width: 25,
            ),
            label: ('智能体'),
          ),
          BottomNavigationBarItem(
            icon: Image.asset(
              'assets/images/mine_unselect.webp',
              height: 20,
              width: 20,
            ),
            activeIcon: Image.asset(
              'assets/images/mine_select.webp',
              height: 25,
              width: 25,
            ),
            label: ('我的'),
          ),
        ],
      ),
    );
  }
}
